// components/bottomTab/bottomTab.js
Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
  },

  /**
   * 组件的初始数据
   */
  data: {
    tabStatus: [
      { prop: 'book', label: '首页', iconnormal: './images/icon-tabbar-book-default.png', iconselected: './images/icon-tabbar-book-selected.png' },
      { prop: 'myinfo', label: '我的', iconnormal: './images/icon-tabbar-me-default.png', iconselected: './images/icon-tabbar-me-selected.png' }
      ],
    currentStatus: 'book',
    centerImage:'./images/icon-tabbar-add-normal.png',
    normalCenterImage:'./images/icon-tabbar-add-normal.png',
    pressCenterImage: './images/icon-tabbar-add-pressed.png',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /*
     * 内部私有方法建议以下划线开头
     * triggerEvent 用于触发事件
     */

    _bindCenterItemTouchstart(){
      this.setData({
        centerImage: this.data.pressCenterImage,
      })
    },
    _bindCenterItemTouchend(){
      this.setData({
        centerImage: this.data.normalCenterImage,
      })
    },
    _catchCenterItemTab(){
      this.triggerEvent("catchItemTab", { tabItem: -1 })
    },
    _catchItemTab(e){
      this.setData({
        currentStatus: e.currentTarget.dataset.status
      })
      switch (e.currentTarget.dataset.status){
        case this.data.tabStatus[0].prop:
          this.triggerEvent("catchItemTab", { tabItem: 0 })
        break;
        case this.data.tabStatus[1].prop:
          this.triggerEvent("catchItemTab", { tabItem: 1 })
          break;
      }
      
    },
  }
})
